package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.TodoData;
import com.thinkcube.edutainment.service.viewitem.TodoItem;
import com.thinkcube.edutainment.service.viewitem.TodoItem_;

@EBean
public class TodoAdapter extends BaseAdapter {

	List<TodoData> todoData;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		TodoItem todoItem;
		if (convertView == null) {
			todoItem = TodoItem_.build(context);
		} else {
			todoItem = (TodoItem) convertView;
		}

		todoItem.bind(getItem(position));

		return todoItem;
	}

	

	public List<TodoData> getTodoData() {
		return todoData;
	}



	public void setTodoData(List<TodoData> todoData) {
		this.todoData = todoData;
	}



	@Override
	public int getCount() {
		return todoData.size();
	}

	@Override
	public TodoData getItem(final int position) {
		return todoData.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
